<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/7/22
 * Time: 11:28
 */

namespace app\index\controller;


use app\common\model\ConfigsModel;
use think\Controller;
use think\Request;


class Base extends Controller
{
    protected $beforeActionList = [
        'globalReg',
    ];

    protected function globalReg(){
        $menuArr = array(
            array('url'=>'/index.html','cname'=>'首页'),
            array('url'=>'/url.html','cname'=>'短网址'),
            array('url'=>'/qrcode.html','cname'=>'二维码'),
            array('url'=>'/ip.html','cname'=>'IP地址查询'),
            array('url'=>'/mobile.html','cname'=>'手机归属地查询'),
            array('url'=>'/ocr.html','cname'=>'图片转文字'),
            array('url'=>'/image_bed.html','cname'=>'免费图床'),
        );
        $configModel = new ConfigsModel();
        $controller = strtolower(request()->controller());
        $site_name = $configModel->findByCname('site_name');
        $this->assign('site_name',$site_name);
        $this->assign('controller',$controller);
        foreach($menuArr as $key=>$menu){
            if(strpos($menu['url'],$controller) !== false){
                $menu['active'] = 1;
            }else{
                $menu['active'] = 0;
            }
            $menuArr[$key]=$menu;
        }

        unset($key);
        unset($menu);
        $this->assign('menuArr',$menuArr);
    }
}